package com.training.bowlapp.service;

import java.io.Serializable;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import com.training.persistence.dao.PlayerDao;
import com.training.persistence.entity.Player;

@Component
@Service(value="userService")
public class UserServiceImpl implements UserService, Serializable {

	@Autowired
	private PlayerDao playerDao;
	
	public UserServiceImpl(){
		super();
	}
	
	public Player loginPlayer(String userName, String password) {
		return playerDao.findPlayerByUserNameAndPassword(userName, password);
	}

	public boolean isPlayerValid(Player player) {
		if (playerDao.findPlayerByUserName(player.getUserName()) != null) {
			return true;
		} else {
			return false;
		}

	}

	public void resetPlayerPassword(String email) {
		// TODO Auto-generated method stub

	}

	public PlayerDao getPlayerDao() {
		return playerDao;
	}

	public void setPlayerDao(PlayerDao playerDao) {
		this.playerDao = playerDao;
	}

	public List<Player> getAllPlayers() {
		return playerDao.findAllPlayers();
	}

	public Player findPlayer(String userName) {
		return playerDao.findPlayerByUserName(userName);
	}

}
